﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UnityGameUI {
    public class EnumUtils {

        /// <summary>
        /// 将字符串转为指定的枚举类型
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="value">值</param>
        /// <param name="ignoreCase">是否忽略大小写</param>
        /// <returns></returns>
        public static T Parse<T>(string value, bool ignoreCase = true) where T : Enum {
            return (T)Enum.Parse(typeof(T), value, ignoreCase);
        }
        public static T Parse<T>(int value) where T : Enum {
            return Parse<T>(value + "");
        }
    }
}
